{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "# map函数",
   "id": "f02148cbb3771442"
  },
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-10-29T13:18:55.429414Z",
     "start_time": "2024-10-29T13:18:55.426885Z"
    }
   },
   "source": [
    "list1 = [1, 2, 3, 4]\n",
    "r = map(lambda x: x + 2, list1)\n",
    "print(list(r))"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3, 4, 5, 6]\n"
     ]
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-10-30T01:24:34.333809Z",
     "start_time": "2024-10-30T01:24:34.330836Z"
    }
   },
   "cell_type": "code",
   "source": [
    "res = map(lambda x: x + 1 if x == 0 else x + 2 , [0, 1, 0, 2, 0, 3])\n",
    "print(list(res))"
   ],
   "id": "5b1780449c4fe6aa",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 3, 1, 4, 1, 5]\n"
     ]
    }
   ],
   "execution_count": 3
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
